package book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-09-08
 * Time: 8:25
 */
public class BookList {
    ListNode head;

    public BookList(){
        ListNode listNode1 = new ListNode(new Book("未闻花名","长井龙雪",45,"爱情"));
        ListNode listNode2 = new ListNode(new Book("你的名字","新海诚",48,"爱情"));
        ListNode listNode3 = new ListNode(new Book("天气之子","新海诚",56,"爱情"));
        ListNode listNode4 = new ListNode(new Book("咒术回战","芥见下下",46,"战斗"));
        ListNode listNode5 = new ListNode(new Book("一拳超人","ONE",43,"战斗"));
        ListNode listNode6 = new ListNode(new Book("千与千寻","宫崎骏",42,"奇幻"));
        listNode1.next = listNode2;
        listNode2.next = listNode3;
        listNode3.next = listNode4;
        listNode4.next = listNode5;
        listNode5.next = listNode6;
        this.head = listNode1;
    }

    public ListNode getHead() {
        return head;
    }

    public void setHead(ListNode head) {
        this.head = head;
    }

    public int size(){
        int count = 0;
        ListNode cur = this.head;
        while (cur != null){
            count++;
            cur = cur.next;
        }
        return count;
    }
}
